package com.atguigu.gmall;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

/**
 * @Author: 李旭
 * @Time: 14:22
 * @Description:
 */
public class Demo {


    @Autowired
    private RedisTemplate redisTemplate;
    public static void main(String[] args)throws Exception {
        //@RequestBody
        //将JSON串转成POJO对象
        // @ResponseBody
        //将POJO对象转JSON串
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        Map map = new HashMap<>();
        map.put("kkk","vvv");
        map.put("ssfsfs",null);
        map.put("curTime",new Date());
        String string = objectMapper.writeValueAsString(map);
        System.out.println(string);
        //  {"curTime":1620458865131,"kkk":"vvv"}
        //Map map1 = objectMapper.readValue(string, Map.class);

       // redisTemplate.opsForValue().set(K,V);
        //Map h = new HashMap
        //h.put(hk,hv)
        //redisTemplate.opsForHash().put
    }
}
